# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html


flow_min=0
flow_max=0

# 以下重写
class PriceConverterPipeline(object):
    # 

    exchange_rate = 100000000
    def process_item(self, item, spider):
        #   #打印列表第2个到末尾元素
        price1 = float(item['shang'])/self.exchange_rate
        price2 = float(item['shen'])/self.exchange_rate
        total = price1 + price2

        global flow_max
        global flow_min
        if total > 0:
            flow_max=max(total,flow_max)
        if total < 0:
            flow_min = min(total,flow_min)

        # 保留2位小数，string
        item['shang']='%.2f Yi'% price1
        item['shen']='%.2f Yi'% price2
        item['total']='%.2f Yi'% total

        print(item)  
        print('flow_max ', flow_max)  
        print('flow_min ', flow_min)  

        # return item  # 返回的数据给下一个pipe line 处理

